package com.ygqh.baby.service;

import com.ygqh.baby.ao.Message;
import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.ao.ResultSet;
import com.ygqh.baby.ao.YgQuartzJob;
import com.ygqh.baby.model.PromotionTag;
import com.ygqh.baby.model.SchJob;
import com.ygqh.baby.po.ScheduleJob;
import com.ygqh.baby.po.YgOrder;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface ScheduleJobService {

    List<ScheduleJob> find();

    int findCount();

    ScheduleJob findById(Long id);

    int deleteSoft(Long[] ids);

    int deleteSoft(Long id);

    int save(ScheduleJob scheduleJob);

    int update(ScheduleJob scheduleJob);

    int saveOrUpdate(ScheduleJob scheduleJob);

    ResultSet<ScheduleJob> search(QueryInfo queryInfo, String q, String groupName, Date startDate, Date endDate);

    List<ScheduleJob> findJobs(String runStatus, String jobType, String ipAddr, Boolean hasNum);

    Boolean exitJob(String jobName, String jobGroup);

    ScheduleJob getJob(String jobName, String jobGroup);

    int updateCron(Long jobId, String cron);

    Message addJobToSchedule(ScheduleJob scheduleJob);

    Message updateJobToSchedule(ScheduleJob scheduleJob);

    Message deleteJobToSchedule(ScheduleJob scheduleJob);

    int updateCronByJobKey(String jobName, String jobGroup, String cron, Date cronDate, String handler);

    Message addBalanceJob(Long orderId, Date sendTime, String handler);

    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    Message addJob(YgQuartzJob quartzJob, String name, Date excuteTime, Map<String, Object> dataMap, String handler, Integer jobTimes);

    void addBalanceJobBatch(List<YgOrder> orderList, String handler);

    Message addBalanceJobByRof(Long orderId, String trueName);

    void sendErrorMail(ScheduleJob scheduleJob, String msg);

    List<SchJob> getAllJobFromSchedule();

    Message addCancelAgentJob(Long agentId, Date updateTime, String cancelBy);

    Message deleteJob(String jobName, String jobGroup, String handler);

    List<ScheduleJob> findJobByJobNames(String... jobNames);

    int updateByJobKey(ScheduleJob scheduleJob);

    /**
     * 该方法会同步到schedule 容器
     *
     * @param quartzJob
     * @param name
     * @param excuteTime
     * @param dataMap
     * @param handler
     * @return Message    返回类型
     * @throws
     * @Title: addJob
     * @author （guohao）
     * @date 2018年7月3日 下午6:07:50
     * @version V1.0
     */
    Message addJob(YgQuartzJob quartzJob, String name, Date executeTime, Map<String, Object> dataMap, String handler);

    Message addTrustonePushOrderJob(String orderCode, Date executeTime, String string);

    Message updatePromotionTag(Long relateId, PromotionTag promotionTag);

    /**
     * 获取任务列表
     *
     * @param groupName 任务分组
     * @param hasNum    未执行
     * @return List<ScheduleJob>
     */
    List<ScheduleJob> findJobList(String groupName, Boolean hasNum);

    List<ScheduleJob> getJobFromQuartz(String groupName, String jobName);
}
